<!--
 * @Author: your name
 * @Date: 2021-06-24 16:12:49
 * @LastEditTime: 2021-06-25 15:56:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\项目\briup-ui\src\pages\admin\log\List.vue
-->
<template>
  <div>
    <!-- 表格 -->
    <div class="table">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column type="index" label="序号" align="center" />
        <el-table-column prop="realname" label="访问人真实姓名" align="center" />
        <el-table-column prop="method" label="访问方式" align="center" />
        <el-table-column prop="content" label="访问路径" align="center" />
        <el-table-column
          prop="logTime"
          label="访问时间"
          align="center"
        >
          <template slot-scope="scope">
            <!--scope为接受的表格所有数据.row是该行数据.add_time为该行的毫秒数据  -->
            {{ scope.row.logTime | dateFormat }}
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="page-div">
      <el-pagination
        :current-page="params.page"
        :page-sizes="[10, 20, 30, 40, 50]"
        :page-size="params.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { pageQuerybaseLog, savebaseLog } from '@/api/log'
export default {
  data() {
    return {
      tableData: [],
      params: {
        page: 1,
        pageSize: 10
      },
      // 总条数
      total: 0
    }
  },
  computed: {},
  watch: {
    // 深度监听分页参数
    params: {
      handler() {
        this.findtableData()
      },
      deep: true
    }
  },
  created() {
    this.findtableData()
  },
  mounted() {},
  methods: {
    // 获取数据
    async findtableData() {
      const res = await pageQuerybaseLog(this.params)
      this.tableData = res.data.list
      this.total = res.data.total
    },
    // 每页显示的条数发生变化时的事件处理程序
    handleSizeChange(val) {
      this.params = {
        page: 1,
        pageSize: val
      }
    },
    // 当前页码发生变化时的事件处理程序
    handleCurrentChange(val) {
      this.params.page = val
    }
  }
}
</script>
<style scoped>
</style>
